package org.lanqiao.api.product;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.PageModel;
import org.lanqiao.pojo.ProductPOJO;
import org.lanqiao.service.ProductServiceImpl;



/**
 * 全部商品搜索，默认排序 返回商品所有信息及销量，并分页传入参数 page第几页 pagesize页面大小
 */
@WebServlet("/api/product/defaultproduct")
public class SelectProductDefaultServlet extends HttpServlet {
	//查询总商品
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String page=request.getParameter("page");
		String pagesize=request.getParameter("pagesize");
		JsonResult result=null;
		try {
			ProductServiceImpl productService=new ProductServiceImpl();
			PageModel<List> list=productService.productAllService(page, pagesize);
			if(list!=null) {
				result=new JsonResult("查询成功",Constants.STATUS_SUCCESS,list);
			}else {
				result=new JsonResult("查询失败",Constants.STATUS_UNFOUND);
			}
		}catch(Exception e){
			result=new JsonResult("查询异常",Constants.STATUS_FAILURE);
		}
		JsonResultWriter.writer(response,result);
	}
	
	


}
